<section id="content">

    <div class="page page-fullwidth-layout">

        <div class="pageheader">

            <h2>{$data.module_name}</h2>

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="{:url('/admin')}"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                    <li>
                        <a href="{:url($data.module_url)}">{$data.module_name}</a>
                    </li>
                    <li>
                        部门调配
                    </li>

                </ul>

            </div>

        </div>

        <div class="pagecontent">



            <div class="add-nav">
                <div class="nav-heading">
                    <h3>部门调配</h3>
                    <span class="controls pull-right">
                        <a href="{:url($data.module_url)}" class="btn btn-ef btn-ef-1 btn-ef-1-default btn-ef-1a btn-rounded-20 mr-5" data-toggle="tooltip" title="返回"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>
                    </span>
                </div>

                <!-- row -->
                <div class="row">
                    <!-- col -->
                    <div class="col-md-12">


                        <!-- tile -->
                        <section class="tile">

                            <!-- tile header -->
                            <div class="tile-header dvd dvd-btm">
                                <h1 class="custom-font"><strong>{$item.username} </strong> 调配信息</h1>
                            </div>
                            <!-- /tile header -->



                            <!-- tile body -->
                            <div class="tile-body">

                                <form role="form" enctype="multipart/form-data" action="{:url($data.module_url).'user_group_add'}" method="post">
                                    <input type="hidden" name="user_id" value="{$item.id}">
                                    {include file="custom-fields" /}
                                    <button class="btn btn-lg btn-primary" type="submit"><i class="glyphicon glyphicon-ok"></i>&nbsp;提交</button>
                    			</form>

                            </div>
                            <!-- /tile body -->

                        </section>
                        <!-- /tile -->
                    </div>
                </div>
            </div>



        </div>

    </div>
    <script type="text/javascript">
        $(document).ready(function(){
            //默认选中部门和角色
            var group_id = "<?= isset($user_group_role) ? $user_group_role['group_id'] : 0 ?>";
            var role_id  = "<?= isset($user_group_role) ? $user_group_role['role_id'] : 0 ?>";

            $('select[name = group_id]').val(group_id);
            $('select[name = role_id ]').val(role_id);

            $('select[name = group_id]').change(function(){
                $('select[name=role_id ]').html('');
                var group_id = $(this).val();
                if(group_id > 0) {
                    $.ajax({
                        type:"POST",
                        url:"{:url($data.module_url.'getRolesByGroupId')}",
                        data: {group_id:group_id},
                        dataType: 'json',
                        success:function(res){
                            if(res.code == 200){
                                if(res.data.length > 0){
                                    var i;
                                    var str = '';
                                    for(i=0;i<res.data.length;i++){
                                        str += '<option value="'+res.data[i].role_id+'">'+res.data[i].name+'</option>';
                                    }
                                    // alert(str);
                                    $('select[name=role_id ]').html(str);
                                }
                            }
                        }
                    });
                }
            })
        })
    </script>
</section>
<!--/ CONTENT -->